﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Input.Dao;
using Shpm.App.Input.Bean;
using Shpm.App.Commons.Utils;

public partial class App_Input_PhysicalUpdateForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            txtPersonId.Text = (string)Context.Items["PERSON_ID"];

            if(Context.Items["LST_LOAD"]!=null) ViewState["LST_LOAD"] = (bool)Context.Items["LST_LOAD"];
            //ViewState["TXT_PHYSICALNO"] = (string)Context.Items["TXT_PHYSICALNO"];
            ViewState["TXT_PERSONID"] = (string)Context.Items["TXT_PERSONID"];
            ViewState["TXT_NAME"] = (string)Context.Items["TXT_NAME"];
            ViewState["TXT_DATE"] = (string)Context.Items["TXT_DATE"];
            ViewState["TXT_END_DATE"] = (string)Context.Items["TXT_END_DATE"];
        }
    }

    //新规按钮
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (ComValidator1.DoValidator())
        {
            PhyscalBean dataBean = new PhyscalBean();
            PhyscalDao Dao = new PhyscalDao();
            dataBean.PersonId = int.Parse(txtPersonId.Text);
            if (Dao.PersonLoad(dataBean) != null)
            {
                Context.Items["PERSON_ID"] = txtPersonId.Text;
                // Server.Transfer("PhysicalRegisteForm.aspx");
                ControllerUtils.Transfer(Context, "~/App/Input/PhysicalRegisteForm.aspx");
            }
            else
            {
                string strErr = HttpContext.GetGlobalResourceObject("Message", "E0203") as string;
                ((Design_MasterPage)this.Master).InfoMessage = strErr.Replace("{0}", "人员编号");
            }
        }
    }

    //返回按钮
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Context.Items["LST_LOAD"] = ViewState["LST_LOAD"];
        //Context.Items["TXT_PHYSICALNO"] = ViewState["TXT_PHYSICALNO"];
        Context.Items["TXT_PERSONID"]=ViewState["TXT_PERSONID"] ;
        Context.Items["TXT_NAME"]=ViewState["TXT_NAME"] ;
        Context.Items["TXT_DATE"]=ViewState["TXT_DATE"] ;
        Context.Items["TXT_END_DATE"] = ViewState["TXT_END_DATE"];
        //ViewState["TXT_END_DATE"] = (string)Context.Items["TXT_END_DATE"];
        // Server.Transfer("PhysicalSearchForm.aspx");
        ControllerUtils.Transfer(Context, "~/App/Input/PhysicalSearchForm.aspx");
    }
}
